//
//  SwiftUIText.swift
//  SwiftUICode
//
//  Created by yangkl on 2024/2/18.
//

import SwiftUI

struct SwiftUIText: View {
    var body: some View {
        // 显示简单文字
        Text("Stay Hungry. Stay Foolish")
        // 修改字体
            .fontWeight(.bold)
        // font 修饰器可以让你修改字体属性
        // .font(.headline)
            .font(.system(size: 28))
            .foregroundColor(.green)
        
    }
}

struct SwiftUIMultiText: View {
    var body: some View {
        // 多行文字的处理
        Text("Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma—which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition.")
            .fontWeight(.bold)
            .font(.title)
            .foregroundColor(.blue)
        //            .multilineTextAlignment(.leading)
        // 多行对齐方式
            .multilineTextAlignment(.center)
        // 显示行数限制
            .lineLimit(nil)
        // 文字的截断模式
            .truncationMode(.head)
        // 设置行间距
            .lineSpacing(10)
        // 文字旋转
//            .rotationEffect(.degrees(45), anchor: UnitPoint(x: 0.5 , y: 0.5))
        // 3D文字旋转
            .rotation3DEffect(
                .degrees(45),axis: (x: 1.0, y: 0.0, z: 0.0)
            )
        // 阴影效果
            .shadow(color: .gray, radius: 2,  x: 0, y: 15)
        // 设置内边距
            .padding()
    }
}

struct SwiftUIMarkdown: View {
    var body: some View {
        Text("**This is how you bold a text**. *This is how you make text italic.* You can [click this link](https://www.appcoda.com) to go to appcoda.com")
            .font(.title)
    }
}

#Preview {
    SwiftUIText()
}
#Preview {
    SwiftUIMultiText()
}
#Preview {
    SwiftUIMarkdown()
}
